/**
* @ingroup Pager
*/
+use MediaWiki\MediaWikiServices;
+
class NewPagesPager extends ReverseChronologicalPager {
/**
$conds = [];
$conds['rc_new'] = 1;
- $namespace = $this->opts->getValue( 'namespace' );
- $namespace = ( $namespace === 'all' ) ? false : intval( $namespace );
-
$username = $this->opts->getValue( 'username' );
$user = Title::makeTitleSafe( NS_USER, $username );
}
}
- if ( $namespace !== false ) {
- if ( $this->opts->getValue( 'invert' ) ) {
- $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
- } else {
- $conds['rc_namespace'] = $namespace;
- }
- }
-
if ( $user ) {
$conds[] = ActorMigration::newMigration()->getWhere(
$this->mDb, 'rc_user', User::newFromName( $user->getText(), false ), false
)['conds'];
- } elseif ( User::groupHasPermission( '*', 'createpage' ) &&
+ } elseif ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->groupHasPermission( '*', 'createpage' ) &&
$this->opts->getValue( 'hideliu' )
) {
# If anons cannot make new pages, don't "exclude logged in users"!
$conds[] = ActorMigration::newMigration()->isAnon( $rcQuery['fields']['rc_user'] );
}
+ $conds = array_merge( $conds, $this->getNamespaceCond() );
+
# If this user cannot see patrolled edits or they are off, don't do dumb queries!
if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
$conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
$fields = array_merge( $rcQuery['fields'], [
'length' => 'page_len', 'rev_id' => 'page_latest', 'page_namespace', 'page_title'
] );
- $join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ] ] + $rcQuery['joins'];
+ $join_conds = [ 'page' => [ 'JOIN', 'page_id=rc_cur_id' ] ] + $rcQuery['joins'];
// Avoid PHP 7.1 warning from passing $this by reference
$pager = $this;
return $info;
}
+ // Based on ContribsPager.php
+ function getNamespaceCond() {
+ $namespace = $this->opts->getValue( 'namespace' );
+ if ( $namespace === 'all' || $namespace === '' ) {
+ return [];
+ }
+
+ $namespace = intval( $namespace );
+ $invert = $this->opts->getValue( 'invert' );
+ $associated = $this->opts->getValue( 'associated' );
+
+ $eq_op = $invert ? '!=' : '=';
+ $bool_op = $invert ? 'AND' : 'OR';
+
+ if ( !$associated ) {
+ return [ "rc_namespace $eq_op " . $this->mDb->addQuotes( $namespace ) ];
+ }
+
+ $associatedNS = MediaWikiServices::getInstance()->getNamespaceInfo()->getAssociated( $namespace );
+ return [
+ "rc_namespace $eq_op " . $this->mDb->addQuotes( $namespace ) .
+ $bool_op .
+ " rc_namespace $eq_op " . $this->mDb->addQuotes( $associatedNS )
+ ];
+ }
+
function getIndexField() {
return 'rc_timestamp';
}